package insight.google.game.era.core;

import java.io.Serializable;

import javax.jdo.annotations.PersistenceCapable;

import org.apache.tools.ant.types.selectors.ExtendSelector;

import insight.google.game.era.bo.GameUser;
import insight.google.game.era.core.exception.InsightException;
import insight.google.game.era.data.Card;
import insight.google.game.era.data.Player;
import insight.google.game.era.data.User;

/**
 * Room Interface for all room function definition.
 * Implementation class need to have dataVersion data.
 * 
 * for publicData(), it sends latest game data with data version to each online user 
 * in this room.(Client must record this data version to pass it to server in each game request 
 * for consistence check. Also check whether there is any user disconnected. if user is disconnected 
 * for 3 times, then just automatically logout him.
 * @author MMC
 *
 */

public interface IGameRoom extends IServerClientData  {
	/**
	 * need to update dataVersion of GameCenter and itself.
	 * call publicData() after processing.
	 * @param user
	 * @return
	 * @throws InsightException
	 */
	public boolean join(GameUser user) throws InsightException;
	//public boolean joinUser(Player player) throws InsightException;
	
	/**
	 * need to update dataVersion of GameCenter and itself.
	 * call publicData() after processing.
	 * @param player
	 * @return
	 * @throws InsightException
	 */
	public boolean notifyUserQuit(GameUser user) throws InsightException;
	//public boolean quitUser(Player player) throws InsightException;
	
	/**
	 * play card from specified user to specified users.
	 * User PolicyCenter to execute policies in this card.
	 * update dataVersion and call publicData() after processing.
	 * @param card
	 * @param fromUserId
	 * @param toUserIds
	 * @return
	 * @throws InsightException
	 */
	public boolean sendCard(String jsId, GameUser user, String targets[], String cardId) throws InsightException;
	//public boolean playCard(Card card, String fromUserId, String[] toUserIds) throws InsightException;
	
	/**
	 * update dataVersion and call publicData() after processing.
	 * @param user
	 * @return
	 * @throws InsightException
	 */
	public boolean start(GameUser user) throws InsightException;
	//public boolean gameStart(Player user) throws InsightException;
	
	/**
	 * update dataVersion and call publicData() after processing.
	 * @return
	 * @throws InsightException
	 */
	public boolean gameOver(GameUser user) throws InsightException;
	//public boolean gameEnd() throws InsightException;
	
	/**
	 * pass turn to next user.
	 * update dataVersion and call publicData() after processing.
	 * @return
	 * @throws InsightException
	 */
	public boolean finishPlay(GameUser user) throws InsightException;
	//public boolean rollGame() throws InsightException;
	
	/**
	 * update dataVersion and call publicData() after processing.
	 * @return
	 * @throws InsightException
	 */
	public boolean discardRoleCard(User user) throws InsightException;
	//public boolean assignRole() throws InsightException;
	
	/**
	 * update dataVersion and call publicData() after processing.
	 * @return
	 * @throws InsightException
	 */
	public boolean discardCharacterCards(User user) throws InsightException;
	//public boolean assignCharacter() throws InsightException;
}
